﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;


namespace SelfService.DataAccess.Migrations
{
    public partial class 更新支付表 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<Guid>(
                name: "PayTypeId",
                table: "SysPays",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true)
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AlterColumn<Guid>(
                name: "PatientId",
                table: "SysPays",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true)
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddColumn<string>(
                name: "AuthCode",
                table: "SysPays",
                type: "varchar(512)",
                maxLength: 512,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPays_SysPatients_PatientId",
                table: "SysPays",
                column: "PatientId",
                principalTable: "SysPatients",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_SysPays_SysPayTypes_PayTypeId",
                table: "SysPays",
                column: "PayTypeId",
                principalTable: "SysPayTypes",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysPays_SysPatients_PatientId",
                table: "SysPays");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPays_SysPayTypes_PayTypeId",
                table: "SysPays");

            migrationBuilder.DropColumn(
                name: "AuthCode",
                table: "SysPays");

            migrationBuilder.AlterColumn<Guid>(
                name: "PayTypeId",
                table: "SysPays",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AlterColumn<Guid>(
                name: "PatientId",
                table: "SysPays",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPays_SysPatients_PatientId",
                table: "SysPays",
                column: "PatientId",
                principalTable: "SysPatients",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPays_SysPayTypes_PayTypeId",
                table: "SysPays",
                column: "PayTypeId",
                principalTable: "SysPayTypes",
                principalColumn: "ID");
        }
    }
}
